<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>我发布的项目</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/gatherInfo/project/list.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">项目名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="title" autocomplete="off" class="layui-input"
                                           value="${project.title}" placeholder="请输入查询项目名称">
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal"
                                       href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">发布时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col>
                            <col>
                            <col width="100">
                            <col width="100">
                            <col width="170">
                            <col width="330">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>项目名称</th>
                            <th>发布者</th>
                            <th>小组数量</th>
                            <th>收集人数</th>
                            <th>发布时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="project" items="${projectList}">
                            <tr class="detail-content1">
                                <td class="table-member" title="${project.title}">
                                    <div class="member-name ellipsis-1">${project.title}</div>
                                </td>
                                <td class="table-member"
                                    onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${project.memberId}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img"
                                        >
                                            <img src="<c:if test="${project.memberLogo != null}">${project.memberLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1"><a class="blue"
                                                                               title="${project.memberName}"
                                                                               href="javascript:void(0);">${project.memberName}</a>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <div>${project.groupNum}</div>
                                </td>
                                <td>
                                    <div>${project.totalNum}</div>
                                </td>
                                <td>
                                    <div><fmt:formatDate value="${project.updateDate}"
                                                         pattern="yyyy-MM-dd HH:mm"/></div>
                                </td>
                                <td class="opts-btns tb-opts" style="width:350px">
                                    <div class="comm-opts">
                                        <a class="qr-btn" href="javascript:txz.openQrDialog({
											title:'扫码二维码可预览分享',
											detailList:[{
												title:'基本信息二维码',
												url:'${project.baseQrCodeUrl}'
											},{
											    title:'保险信息二维码',
												url:'${project.insuranceQrCodeUrl}'
											},{
											    title:'行程信息二维码',
												url:'${project.itineraryQrCodeUrl}'
											}]
										})">二维码</a>
                                        <a href="${ctx}/gatherInfo/member/list.do?projectId=${project.id}">人员管理</a>
                                        <a href="${ctx}/gatherInfo/group/list.do?projectId=${project.id}">小组管理</a>
                                        <a class="green"
                                           href="${ctx}/gatherInfo/project/toForm.do?id=${project.id}">编辑</a>
                                        <a class="red"
                                           href="javascript:txz.deleteObject('确定要删除吗？', '${ctx}/gatherInfo/project/delete.do?id=${project.id}','', '#myForm');">删除</a>
                                        <a href="javascript:txz.expireCheck('', function() { createCompetition('${project.id}') })">生成赛事项目</a>
                                        <a href="javascript:txz.expireCheck('', function() { createCircle('${project.id}') })">生成圈子</a>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <c:if test="${page.totalCount == 0}">
                        <div class="f16 tc mt15">还没有项目</div>
                    </c:if>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">

    <%--showActive('${input.createStart}', '${input.createEnd}', '#timeType');--%>
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });
        //加载日历
        layui.use(['element', 'laydate'], function () {
            var laydate = layui.laydate, element = layui.element;
            element.on('tab(type)', function (data) {
                if (data.index == 0) {
                    $('#status').val(0);
                    $('#myForm').submit();
                } else if (data.index == 1) {
                    $('#status').val(1);
                    $('#myForm').submit();
                }
            });

            // 查询开始日期
            var start = {
                elem: 'input[name=s_start]'
            };

            var end = {
                elem: 'input[name=s_end]'
            };
            laydate.render(start);
            laydate.render(end);

            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })

    function createCompetition(id) {
        var content = "确定要生成吗？";
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var type = $("[name=type]:checked").val() || '2';
            layer.close(index);
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/gatherInfo/project/syncCompetition.do", {
                id: id,
                type: type
            }, function (data) {
                layer.close(loadIndex);
                setTimeout(function () {
                    if (data.success) {
                        util.layerMsgSuccess("生成成功")
                    } else {
                        util.layerMsgError("生成失败")
                    }
                }, 500);// 延时0.1秒
            })
        });
    }

    function createCircle(infoId) {
        var content = "确定要生成吗？";
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            layer.close(index);
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/gatherInfo/project/createCircle.do", {
                infoId: infoId
            }, function (data) {
                layer.close(loadIndex);
                setTimeout(function () {
                    if (data.success) {
                        util.layerMsgSuccess("生成成功")
                    } else {
                        util.layerMsgError("生成失败")
                    }
                });
            })
        });
    }

    function openHelpDialog() {
        txz.openHelpDialog({
            title: '手机效果预览',
            describe: '可以收集参与活动人员的基本信息、紧急联系人信息、航班信息，用户在手机即可填写信息。',
            detailList: [{
                text: '1/基本信息',
                url: '${ctx}/image/dialog/gai_1.jpg'
            }, {
                text: '2/保险信息',
                url: '${ctx}/image/dialog/gai_2.jpg'
            }, {
                text: '3/行程信息',
                url: '${ctx}/image/dialog/gai_3.png'
            }]
        })
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '我发布的项目',
            curr: true
        }],
        info: '<span class="f14 gray">人员信息收集分组主要是针对参与活动的人员进行信息收集。' +
        '<a href="javascript:openHelpDialog()" class="red ml10"><i class="iconfont icon-mobile"></i>手机端效果</a>\n' +
        '<a href="${ctx}/help/help/list.do?id=2268af44b02a4a988c05abc7868660c3" class="red ml10" target="_blank"><i class="iconfont icon-book"></i>帮助教程</a>',
        btns: [{
            name: '发布项目',
            icon: 'add',
            href: '${ctx}/gatherInfo/project/toForm.do',
            isCheckExpire: true
        }]
    });
</script>
</body>
</html>